package com.example.plugin.service;

import com.example.plugin.dto.PluginDto;
import org.noear.solon.annotation.Component;
import org.noear.solon.data.annotation.Cache;
import org.noear.solon.data.cache.impl.JavabinSerializer;
import org.noear.solon.data.cache.impl.JsonSerializer;

/**
 * @author airhead
 */
@Component
public class PluginService {
//    private JavabinSerializer serializer = new JavabinSerializer();
    private JsonSerializer serializer = new JsonSerializer();

    public String hello() {
        return "hello plugin.";
    }

        @Cache(key = "plugin:cache", tags = "plugin")
    public PluginDto cache() {
        System.out.println("get plugin from source");
        PluginDto plugin = PluginDto.builder().id(1L).name("plugin").build();
//        String data = serializer.serialize(plugin);
//        return (PluginDto) serializer.deserialize(data, PluginDto.class);

        return plugin;
    }
}
